def solve(nums):
    n = len(nums)
    steps = 0
    max_reach = 0
    end = 0
    for i in range(n):
        max_reach = max(max_reach, i + nums[i])
        if i == end and i != n - 1:
            steps += 1
            end = max_reach

    return steps


if __name__ == "__main__":
    nums = [2, 3, 0, 1, 4]
    print(solve(nums))
